package realdance.swing.outline;

import java.awt.BorderLayout;
import java.awt.EventQueue;

import javax.swing.JFrame;
import javax.swing.JPanel;
import javax.swing.border.EmptyBorder;
import javax.swing.JTabbedPane;
import javax.swing.JButton;
import javax.swing.JRadioButton;
import javax.swing.JTextField;
import java.awt.Color;
import javax.swing.ImageIcon;
import javax.swing.JSpinner;

/* JTabbedPane
 * 여러가지 컴퍼넌트들을 그룹화해서
 * 각각의 탭으로 만든 후 클릭하면 그것을 표시하는 컴퍼넌트
 * 한 화면에서 많은 영역을 표시할 수 있어 편리함
 * 
 */


public class J23_AdvancedComponent extends JFrame {

	private JPanel contentPane;
	private JTextField textField;

	/**
	 * Launch the application.
	 */
	public static void main(String[] args) {
		EventQueue.invokeLater(new Runnable() {
			public void run() {
				try {
					J23_AdvancedComponent frame = new J23_AdvancedComponent();
					frame.setVisible(true);
				} catch (Exception e) {
					e.printStackTrace();
				}
			}
		});
	}

	/**
	 * Create the frame.
	 */
	public J23_AdvancedComponent() {
		setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
		setBounds(100, 100, 450, 300);
		contentPane = new JPanel();
		contentPane.setBorder(new EmptyBorder(5, 5, 5, 5));
		contentPane.setLayout(new BorderLayout(0, 0));
		setContentPane(contentPane);
		
		JTabbedPane tabbedPane = new JTabbedPane(JTabbedPane.TOP);
		contentPane.add(tabbedPane, BorderLayout.CENTER);
		
		JPanel panel_2 = new JPanel();
		tabbedPane.addTab("FaceBook", new ImageIcon(J23_AdvancedComponent.class.getResource("/img/new3.png")), panel_2, null);
		tabbedPane.setBackgroundAt(0, Color.PINK);
		
		textField = new JTextField();
		panel_2.add(textField);
		textField.setColumns(10);
		
		// 탭페인 생성
		JPanel panel = new JPanel();
		// 탭페인에 패널 추가(addTab)
		tabbedPane.addTab("Twitter", new ImageIcon(J23_AdvancedComponent.class.getResource("/img/new2.png")), panel, null);
		tabbedPane.setBackgroundAt(1, Color.ORANGE);
		
		JButton btnNewButton = new JButton("New button");
		panel.add(btnNewButton);
		
		JPanel panel_3 = new JPanel();
		tabbedPane.addTab("Google", new ImageIcon(J23_AdvancedComponent.class.getResource("/img/new4.png")), panel_3, null);
		tabbedPane.setBackgroundAt(2, Color.GREEN);
		
		JRadioButton rdbtnNewRadioButton = new JRadioButton("New radio button");
		panel_3.add(rdbtnNewRadioButton);
	}

}
